package xio.ccf_201409;

import java.util.PriorityQueue;
import java.util.Scanner;
/**
 * 201409-1 相邻数对  100分
 * 使用优先队列来存储（从小到大排序），比较相邻两个数
 * @author xio
 *
 */
public class AdjacentNumPair {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		PriorityQueue<Integer> queue = new PriorityQueue<>();
		for (int i = 0; i < n; i++) {
			queue.add(sc.nextInt());
		
		}
		
		int count = 0;
		int pre = queue.poll();
		while (!queue.isEmpty()) {
			int cur = queue.poll();
			if (cur -pre == 1) {
				count++;
			}
			pre = cur;
		}
		System.out.println(count);
	}
}
